package com.project.poetry.service.controller;

import com.project.poetry.service.entity.dto.forum.ForumListDTO;
import com.project.poetry.service.entity.dto.forum.ReleaseForumDTO;
import com.project.poetry.service.entity.po.user.UserPO;
import com.project.poetry.service.service.ForumService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

/**
 * 论坛控制器
 * @author mengxj
 */
@Api("论坛")
@RestController
@RequestMapping("forum")
public class ForumController {

    @Resource
    private ForumService forumService;

    @ApiOperation("发布帖子")
    @PostMapping("releaseForum")
    public void releaseForum(@RequestBody ReleaseForumDTO releaseForum, @ApiIgnore UserPO user){
        this.forumService.releaseForum(releaseForum, user);
    }

    @ApiOperation("论坛查询")
    @GetMapping("forumList")
    public List<ForumListDTO> forumList(@RequestParam(value = "userId", required = false) Long userId){
        return this.forumService.forumList(userId);
    }

    @ApiOperation("删除帖子")
    @DeleteMapping("deleteById/{forumId}")
    public void deleteById(@PathVariable("forumId") Long forumId){
        this.forumService.deleteById(forumId);
    }
}
